#ifndef DVADDDATAFROMDATABASEDIALOG_H
#define DVADDDATAFROMDATABASEDIALOG_H

#include <QDialog>
#include "dvDatabaseController.h"
#include "dvDatabaseControllerUsable.h"

namespace Ui {
class dvAddDataFromDatabaseDialog;
}

class QTableView;
class QSqlQueryModel;
class QSqlQuery;

class dvAddDataFromDatabaseDialog : public QDialog, public dvDatabaseControllerUsable
{
    Q_OBJECT
    
public:
    explicit dvAddDataFromDatabaseDialog(QWidget *parent = 0);
    ~dvAddDataFromDatabaseDialog();
    void Initialize();

    inline void setMapId(int id){ m_mapId = id; }
    inline void setMapName(const QString& name){ m_mapName = name; }
    inline const DV_INDICATOR& getIndicator(){ return m_indicator; }
    inline QSqlQuery* getData(){ return m_pData; }
    inline int recordsCount(){ return m_records; }
    
private:
    Ui::dvAddDataFromDatabaseDialog *ui;
    int       m_records;
    int       m_mapId;
    QString   m_mapName;
    DV_INDICATOR m_indicator;

    QTableView     *m_pTable;
    QSqlQueryModel *m_pModel;
    QSqlQuery      *m_pData;

    void fillTable(QSqlQuery *query);

private slots:
    void clickedAllRegions(bool state);
    void clickedAllTime(bool state);
    void currentRegionChanged(int index);
    void currentIndicatorChanged(int index);
    void dateChanged();
    void clickedOk();
    void clickedCancel();
};

#endif // DVADDDATAFROMDATABASEDIALOG_H
